package com.vvlive.caibao.smartcity.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.vvlive.caibao.smartcity.adapter.CustomersContactsAdapter;
import com.vvlive.caibao.smartcity.base.BaseActivity;
import com.vvlive.caibao.smartcity.data.BaseData;
import com.vvlive.caibao.smartcity.view.CommonActionBar;

import org.kymjs.kjframe.ui.BindView;

import java.io.Serializable;

import smartcity.vvlive.caibao.com.smartc.R;

/**
 * Created by zhj on 2015/6/29.
 */
public class CustomersContactsActivity extends BaseActivity implements AdapterView.OnItemClickListener {

    @BindView(id = R.id.cc_list)
    private ListView mList;
    @Override
    protected int getContentViewRes() {
        return R.layout.activity_customers_contacts;
    }

    @Override
    public void initWidget() {
        super.initWidget();
        CommonActionBar commonActionBar = super.getCommonActionBar();
        commonActionBar.setMoreVisible(false);
        commonActionBar.setTitle("客户通讯录");
        mList.setAdapter(new CustomersContactsAdapter(this, BaseData.getContactData()));
        mList.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent intent = new Intent(this, CustomersContactDetailsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Bundle data = new Bundle();
        data.putSerializable("contact", (Serializable) parent.getItemAtPosition(position));
        intent.putExtras(data);
        startActivity(intent);
    }
}
